<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js</title>
    <script>
        function add(a,b){
            console.log(a+b);
            return a+b;
        }
        var c=add(1,2)
        console.log('🚀 - c:', c);
        var myadd=function(a,d){
            return a+b;
        }
        var d=add(1,2);
        console.log('🚀 - d:', d)
    </script>
    <!-- <script src="D:\Users\86156\Desktop\Html\day50\js\index.js"></script> -->
</head>
<body>
    喜欢的水果：<input id ="inputFruit" type ="text"placeholder="请输入你个喜欢的水果哦"value="苹果">
    <br>
    <!-- 给按钮绑定事件 方式 1 -->
    <input id="btn1"type="button"value="按钮一"onclick="clickBtn1()">
    <input id="btn1"type="button"value="按钮二"onclick="add(1,2)">
    <!-- 方式二 -->
    <input id="btn3"type="button"value="按钮三">
</body>
<script>
    //
    var fruitElement = document.getElementById("inputFruit");
    console.log('🚀 - fruitElement:', fruitElement);
    if(fruitElement){
        var fruitValue = fruitElement.value;
        switch(fruitValue){
            case "苹果":
            alert("用户喜欢苹果");
            break;
            case "香蕉皮":
            alert("用户喜欢香蕉皮");
            break;
        }
    }
    function clickBtn1(){
        console.log('btn1被点击');
    }
    // alert('阻塞运行');
    //获取按钮元素
    var btn3=document.getElementById("btn3");
    console.log('🚀 - btn3:', btn3);
    if(btn3){
        btn3.onclick=function(){
            console.log("btn3被点击");
        }
    }
</script>
</html>